package com.jiashihui.schema_lgorithm.java.socket.handler.common;

/**
 * 分拣信息服务
 * 定义枚举类
 */
public enum ServiceTypeEnum {
    ANCB_PDA_HB(1940, "获取新北洋PDA心跳", true);

    private final int id;
    private final String name;
    //是否返回结果
    private final boolean back;

    ServiceTypeEnum(int id, String name, boolean back) {
        this.id = id;
        this.name = name;
        this.back = back;
    }

    /**
     * 根据id获取
     * 枚举类
     *
     * @param id
     * @return
     */
    public static ServiceTypeEnum getEnumById(Integer id) {
        for (ServiceTypeEnum item : ServiceTypeEnum.values()) {
            if (item.getId() == id) {
                return item;
            }
        }
        throw new RuntimeException("错误的服务类型~");
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public boolean isBack() {
        return back;
    }
}
